package common.filter;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 14505
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<T>(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<T>(ResultCodeEnum.SUCCESS.getCode(), message, data);
    }

    public static <T> Result<T> success(String message) {
        return new Result<T>(ResultCodeEnum.SUCCESS.getCode(), message, null);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<T>(ResultCodeEnum.FAIL.getCode(), message, null);
    }

    public static <T> Result<T> fail(Integer code, String message) {
        return new Result<T>(code, message, null);
    }
}
